<?php
//  event/Form/EventSearch.php
class Form_TourSearch extends Zend_Form
{

    protected $_noDecorator = array(
        'ViewHelper', 
        'Errors'
    );

    public function cluBuild($params)
    {
    	$this->setMethod('POST');
	    //$this->setAction('/en/tour/index/search');
//		if($params['action'] == 'search')
//        {
//        	$actionSearchForm = $params['view']->hvnUrl(array('module' => 'tour', 'action'=>'search'), 'nocontroller');
//        	$this->setAction($actionSearchForm);
//        } 
	    $myValidator = new Zend_Validate_Regex('/^[A-Z0-9_\s\-]*$/i'); //alpha, num, space, -, _
        $myValidator->setMessage(t(60), Zend_Validate_Regex::NOT_MATCH);
		$this->addElementPrefixPath('Clu_Filter', 'Clu/Filter/', 'filter');
		
		$this->setAction($params['action_url']);
		
        //add category
        $category = new Zend_Form_Element_Select('category_tour',  
                 array('disableLoadDefaultDecorators' => true,
                 'required'   => true,  
                 ));
        
    	$mCategory = new category_Model_Category();
        $mCategory->setTables('tour');
        $category	->addMultiOption('none','---'.t(113).'---');
        foreach($mCategory->getRootType('Root_Tour') as $e) {
            $category->addMultiOption($e['id'], p($e['name']));
        }             
        $category->addDecorators($this->_noDecorator);
        $this->addElement($category);
		
        // add the submit button
		$submit = new Zend_Form_Element_Submit('submit', array('disableLoadDefaultDecorators' => true, 
                                                           'label' => t(67) ));
        $submit->setAttrib("class", 'search-button');
        $submit->addDecorators($this->_noDecorator);
        $this->addElement($submit);
		
        //add tours per page
 		$tours_per_page = new Zend_Form_Element_Select('tours_per_page',  
                         array('disableLoadDefaultDecorators' => true));
 		$tours_per_page		->addMultiOption(10,t(62))
                           	->addMultiOption(15,t(111))
                           	->addMultiOption(20,t(63))
                           	->addMultiOption(30,t(64))
                           	->addDecorators($this->_noDecorator);
         $this->addElement($tours_per_page);
		
		$name = new Zend_Form_Element_Text('name', 
                         array('disableLoadDefaultDecorators' => true,
//                               'required'   => true,             
                               'class' => 'inputText'));
        
        $name->addDecorators($this->_noDecorator)
        	 ->addValidator($myValidator);
        $this->addElement($name);
        
        if($params['cluSearchMode'] == 'simpleSearch')
        {
    		//add search quick time
     		$quick_time_range_mode = new Zend_Form_Element_Select('quick_time_range_mode',  
                             array('disableLoadDefaultDecorators' => true));
            $quick_time_range_mode->addMultiOption(1,__('Next 7 days'))
                               	->addMultiOption(2,__('Next 30 days '))
                               	->addMultiOption(3,__('Next 3 months'))
                               	->addDecorators($this->_noDecorator);
            $quick_time_range_mode->setValue(2);
            $this->addElement($quick_time_range_mode);
        
        	return;
        }
        
		//add price
        $price = new Zend_Form_Element_Text('price', 
                         array('disableLoadDefaultDecorators' => true,
//                               'required'   => true,             
                               'class' => 'inputText'));
        
        $price->addDecorators($this->_noDecorator)
        	 ->addValidator($myValidator);
        $this->addElement($price);
        
        //add to_price
        $to_price = new Zend_Form_Element_Text('to_price', 
                         array('disableLoadDefaultDecorators' => true,
//                               'required'   => true,             
                               'class' => 'inputText'));
        
        $to_price->addDecorators($this->_noDecorator)
        	 ->addValidator($myValidator);
        $this->addElement($to_price);
        
        //price currency
        $price_currency = new Zend_Form_Element_Select('price_currency', array('disableLoadDefaultDecorators' => true,));
//                                                                 'required' => true));
        $price_currency->addMultiOption('0','--'.t(97).'--')
                     ->addMultiOption('VND',__('VND'))
                     ->addMultiOption('USD',__('USD'))
                     ->addMultiOption('EURO',__('EURO'))
                     ->addMultiOption('CNY',__('CNY'))
                     ->addMultiOption('JPY',__('JPY'))
                     ->addDecorators($this->_noDecorator);
        $this->addElement($price_currency);
        
        //add start date
        $departure_date= new Zend_Form_Element_Text('departure_date',  
                         array('disableLoadDefaultDecorators' => true,
//                                'required' => true
                         )); 
         
        $departure_date->addDecorators($this->_noDecorator);
        $departure_date->size = 10;
        $this->addElement($departure_date);
        
        //add finish date
        $return_date = new Zend_Form_Element_Text('return_date',  
                         array('disableLoadDefaultDecorators' => true,
//                                'required' => true
                         )); 
        $return_date->size = 10;
        $return_date->addDecorators($this->_noDecorator);
        $this->addElement($return_date);
        
        // duration start
        $duration_start = new Zend_Form_Element_Text('duration_start',  
                         array('disableLoadDefaultDecorators' => true,
//                                'required' => true
                         )); 
        $duration_start->size = 10;
        $duration_start->addDecorators($this->_noDecorator)
//                  ->addFilter($dateValidator)
                  ;
        $this->addElement($duration_start);
        
        // duration finished
        $duration_finished = new Zend_Form_Element_Text('duration_finish',  
                         array('disableLoadDefaultDecorators' => true,
//                                'required' => true
                         )); 
        $duration_finished->size = 10;
        $duration_finished->addDecorators($this->_noDecorator)
//                  ->addFilter($dateValidator)
                  ;
        $this->addElement($duration_finished);
        
        if ($params['cluSearchMode'] == 'fullSearch')
        	return;
        //---------------------------------Admin options ------------------------------
        
        //add poster_id
        $poster_id = new Zend_Form_Element_Text('poster_id', 
                         array('disableLoadDefaultDecorators' => true,
//                             'required'   => true,             
                               'class' => 'inputText'));
        $poster_id->addDecorators($this->_noDecorator)
        	 	  ->addValidator($myValidator);
        $poster_id->size = 10;    
        $this->addElement($poster_id);
        
        //add poster_time
        /*
        $poster_time = new Zend_Form_Element_Text('post_time', 
                         array('disableLoadDefaultDecorators' => true,
//                             'required'   => true,             
                               'class' => 'inputText'));
        $poster_time->addDecorators($this->_noDecorator)
        	 		->addValidator($myValidator);
		$poster_time->size = 10;       
        $this->addElement($poster_time);
        */
        //status
        $status = new Zend_Form_Element_Select('status',  
                         array('disableLoadDefaultDecorators' => true,
//                               'required' => true
                         )); 
        $status->addMultiOption('all','--'.t(61).'--')
        	   ->addMultiOption('featured ',t(33))
        	   ->addMultiOption('published',t(34))
               ->addMultiOption('queued',t(35))
               ->addMultiOption('unpublished',t(36))
               ->addMultiOption('deleted',t(37))
               ->addDecorators($this->_noDecorator);

        $this->addElement($status);
    }
}
?>
